package com.digua.base

import android.app.Activity
import android.content.Context
import android.os.Bundle
import com.blankj.utilcode.util.CrashUtils
import com.blankj.utilcode.util.Utils
import com.digua.base.base.App
import com.digua.base.config.BaseConfig
import com.digua.base.config.Config
import com.digua.base.util.LogUtil
import com.uc.crashsdk.export.CrashApi
import com.umeng.analytics.MobclickAgent
import com.umeng.commonsdk.UMConfigure
import java.util.LinkedList
import kotlin.system.exitProcess

class MyApp : App() {

    companion object {
        val instance: MyApp by lazy(LazyThreadSafetyMode.SYNCHRONIZED) { Utils.getApp() as MyApp }
    }

    override fun onCreate() {
        super.onCreate()
        context = this
        initCrash()
        initUmeng()
        //XUI.init(this) //初始化UI框架
        //XUI.debug(Util.isApkInDebug(context)) //开启UI框架调试日志
        //LitePal.initialize(this)
        //TbsInit.init(this)
        //RecoveryInit.init(this, true)
        //OkHttpUtils.initClient(Builder().connectTimeout(20L, TimeUnit.SECONDS).readTimeout(20L, TimeUnit.SECONDS).build())
    }

    private fun initUmeng() {
        try {
            UMConfigure.preInit(this, Config.umengKey, "Umeng")
            UMConfigure.init(this, Config.umengKey, "Umeng", UMConfigure.DEVICE_TYPE_PHONE, "")
            val customInfo = Bundle()
            customInfo.putBoolean("mCallNativeDefaultHandler", true)
            CrashApi.getInstance().updateCustomInfo(customInfo)
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }
}
